<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue基础模板</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="count++">累加</button>
        <button @click="fullName='xiao yue'">修改</button>
        <h1>{{count}}</h1>
        <input type="text" v-model.trim="surname"><br>
        <input type="text" v-model.trim="name">
        <h2>{{fullName}}</h2>
    </div>

    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    surname: '',
                    name: '',
                    count: 0
                }
            },
            methods: {

            },
            computed: {
                // fullName(){
                //     console.log('fullName被调用了');
                //     return this.surname.toUpperCase()+'-'+this.name.toUpperCase()
                // }
                fullName: {
                    get() {
                        console.log('fullName被调用了');
                        return this.surname.toUpperCase() + '-' + this.name.toUpperCase()
                    },
                    set(value) {
                        [this.surname, this.name] = value.split(' ')
                    }
                }
            }
        })
    </script>
</body>

</html>